#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   14:24
# Author     : Y4
# Site       : 
# File       : 10 集合-增删改查.py
# Software   : PyCharm

print(dir(set))
'''
['__and__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
 '__getattribute__', '__gt__', '__hash__', '__iand__', '__init__', '__init_subclass__', '__ior__', '__isub__',
 '__iter__', '__ixor__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__rand__', '__reduce__',
 '__reduce_ex__', '__repr__', '__ror__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__',
 '__subclasshook__', '__xor__', 'add', 'clear', 'copy', 'difference', 'difference_update', 'discard', 'intersection',
 'intersection_update', 'isdisjoint', 'issubset', 'issuperset', 'pop', 'remove', 'symmetric_difference',
 'symmetric_difference_update', 'union', 'update']
'''

# 新增
set_value = {"hello",123,(1,2,3)}
set_value.add('world')
print(set_value)   # {'world', 123, (1, 2, 3), 'hello'}


# 修改
set_value.update({4,5,6})
print(set_value)  # {4, 'world', 5, 'hello', 6, 123, (1, 2, 3)}

# 删除
'''
del
pop    随机删除一个元素
remove 移除指定的元素  不存在报错
discard 移除指定的元素 不存在不报错,也不改变原集合
'''
# del set_value
# set_value.pop()
# set_value.remove("hello")
set_value.discard("hello")
print(set_value)


# 查询
'''
in
'''
if "hello" in set_value:
 print("yes")
else:
 print("no")


